package com.gcl.rabbirmq;

import com.gcl.rabbirmq.utils.RabbitMQUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Consumer02 {

    public static void main(String[] args) throws IOException, TimeoutException {
        // 获取信道
        Channel channel = RabbitMQUtils.getChannel();

        // 声明交换器
        channel.exchangeDeclare("dead", BuiltinExchangeType.DIRECT);

        // 声明队列
        channel.queueDeclare("dead_queue", false, false, false, null);

        // 队列绑定交换机
        channel.queueBind("dead_queue", "dead_exchange", "lisi");

        DeliverCallback deliverCallback = (a, b) -> {
            System.out.println(new String(b.getBody()));
        };

        channel.basicConsume("dead_queue",true,deliverCallback, (a) -> {});
    }

}
